package binary.type

import binary.ValType
import binary.ValTypeToStr

/**
 *@author haypo
 *@since 2021/7/20
 */
class FuncType(
    val Tag: Byte,
    private val ParamTypes: Array<ValType?>,
    private val ResultTypes: Array<ValType?>
) {
    override fun equals(other: Any?): Boolean {
        if (other is FuncType) {
            return super.equals(other)
        }
        return false;
    }

    private fun getSignature(): String {
        val sb = StringBuilder()
        sb.append("(")
        for (i in ParamTypes.indices) {
            val vt = ParamTypes[i]
            if (i > 0) {
                sb.append(",")
            }
            sb.append(ValTypeToStr(vt))
        }
        sb.append(")->(")
        for (i in ResultTypes.indices) {
            val vt = ResultTypes[i]
            if (i > 0) {
                sb.append(",")
            }
            sb.append(ValTypeToStr(vt))
        }
        sb.append(")")
        return sb.toString()
    }
}